package com.gtenacg.cartoonservice.service.impl;

import com.gtenacg.cartoonservice.mapper.AuthorMapper;
import com.gtenacg.cartoonservice.pojo.model.Author;
import com.gtenacg.cartoonservice.service.AuthorService;
import lombok.RequiredArgsConstructor;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;

import java.sql.SQLIntegrityConstraintViolationException;
import java.util.List;

/**
 * @author 86198
 * @description 针对表【author(作者表)】的数据库操作Service实现
 * @createDate 2024-05-13 16:04:37
 */
@Service
@RequiredArgsConstructor
public class AuthorServiceImpl implements AuthorService {
    private final AuthorMapper authorMapper;

    @Override
    public List<Author> list() {
        return authorMapper.list();
    }

    @Override
    public Integer insert(Author author)
            throws DuplicateKeyException {
        authorMapper.insert(author);
        return author.getAid();
    }

    @Override
    public void update(Author author) {
        authorMapper.update(author);
    }

    @Override
    public void delete(List<Integer> ids) {
        authorMapper.delete(ids);
    }

    @Override
    public List<Author> search(String name, String gender) {
        return authorMapper.search(name, gender);
    }
}




